package controller.expertInfo.expertSeeCheckResult;

import base.response.OffsetLimitPage;
import controller.common.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import services.expertInfo.LeaderCheckServices;
import wt.entity.expertInfo.LeaderCheckExample;

/**
 * Created by Administrator on 2017/12/2.
 */
@Controller
@RequestMapping("expertInfo/expertSeeCheckResult")
public class ExpertSeeCheckResultController extends BaseController {
    @Autowired
    LeaderCheckServices leaderCheckServices;

    @RequiresPermissions("expertInfo:expertSeeCheckResult:default")
    @RequestMapping("index")
    public String index() {
        return "expertInfo/expertSeeCheckResult/index";
    }

    @RequiresPermissions("expertInfo:expertSeeCheckResult:default")
    @RequestMapping("select")
    @ResponseBody
    public OffsetLimitPage select(Integer offset, Integer limit) throws Exception {
        if(getLoginAccount().getExpertBase()==null){//如果不是专家 直接返回
            OffsetLimitPage offsetLimitPage=new OffsetLimitPage();
            offsetLimitPage.setTotal(0L);
            return offsetLimitPage;
        }

        LeaderCheckExample leaderCheckExample = new LeaderCheckExample();
        leaderCheckExample.setOrderByClause("id desc");
        leaderCheckExample.createCriteria().andExpertIdEqualTo(getLoginAccount().getExpertBase().getId());
        OffsetLimitPage offsetLimitPage = leaderCheckServices.selectByExample(leaderCheckExample, offset, limit);
        return offsetLimitPage;
    }







}
